<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  const html1 = '<div>xxxxxxxxx</div>'

  console.log('html1: =>', (html1).match(/<[^>]+>|((?<=[^<]).+?(?=<))/g))
</script>

<script>
  const html2 = '<div>   xxxxxxxxx    </div>'

  console.log('html2: =>', (html2).match(/<[^>]+>|((?<=[^<]).+?(?=<))/g))
</script>

<script>
  const html3 = `
<div>
   xxxxxxxxx
</div>`
  console.log('html3: =>', (html3).match(/<[^>]+>|((?<=>).+?(?=<))/gs))
</script>
</body>
</html>
